package ch04;

public class Land {
    private boolean idle;
    public Crop crop;
    public boolean isIdle() {
        return idle;
    }

    public void setIdle(boolean idle) {
        this.idle = idle;
    }

    public Land() {
        this(true);
    }

    public Land(boolean idle) {
        this.idle = idle;
    }

    public Crop plant(Crop crop, Crop newCrop) { // 多态
        if (!idle){
            System.out.println("该土地被占用，您可以选择其他土地种植"+newCrop.getName()+"。");
        }else{
            this.idle = false;
            crop = newCrop;
            crop.print();// 多态
        }
        return crop;
    }
    public void checkAppleGrow(Crop crop, int day){
        if (!idle){
            crop.printGrowReport(day);
        }else{
            System.out.println("您尚未种植任何农作物！");
        }
    }
    public void harvestCrop(Crop crop){
        if (!idle){
            crop.harvest();
        }else{
            System.out.println("您尚未种植任何农作物！");
        }
    }
}
